package com.wsy.wsyojcodesandbox.unsafe;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;

/**
 * 运行危险程序
 */
public class RunFileErr {
    public static void main(String[] args) throws IOException, InterruptedException {
        String userDir = System.getProperty("user.dir");
        String filePath = userDir + File.separator + "src/main/resources/muma.bat";
        Process process = Runtime.getRuntime().exec(filePath);
        process.waitFor();
        //分批获取控制台输出
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String compileLine;
        while((compileLine = in.readLine()) != null) {
            System.out.println(compileLine);
        }
        System.out.println("执行危险程序成功");
    }
}
